<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/common/hospital_token.jsp"%>
<%
    Integer labelId = input.getInt("label_id", -1);
    String newLabelName = input.getDesc("new_label_name", "").trim();
    if (labelId == -1 || newLabelName.isEmpty()) {
        ErrcodeUtil.setErrcode(msg, ErrcodeUtil.FAILURE);
        Tools.encryptPrint(out, msg);
        return;
    }
    HospitalLabel hospitalLabel = LabelUtil.getHospitalLabelByName(hospital, newLabelName);
    if (hospitalLabel != null) {
        msg.setErrcodeAndErrmsg(ErrcodeUtil.FAILURE, "新标签名已存在");
        Tools.encryptPrint(out, msg);
        return;
    }
    hospitalLabel = LabelUtil.getHospitalLabelById(hospital, labelId);
    if (hospitalLabel == null) {
        msg.setErrcodeAndErrmsg(ErrcodeUtil.FAILURE, "标签不存在");
        Tools.encryptPrint(out, msg);
        return;
    }
    hospitalLabel.setName(newLabelName);
    DBTools.db("basedb").modItem(hospitalLabel, hospitalLabel.getId());
    msg.setErrmsg("修改成功");
    Tools.encryptPrint(out, msg);
%>
